/*
 * Copyright 2017 Baiyyy
 * @(#)ColdStorageService.java
 */

package com.byyy.ccts.modules.cc.service.impl;

import com.baomidou.mybatisplus.mapper.Wrapper;
import com.byyy.ccts.core.common.service.impl.CommonServiceImpl;
import com.byyy.ccts.core.query.data.Page;
import com.byyy.ccts.core.query.data.PageImpl;
import com.byyy.ccts.core.query.data.Pageable;
import com.byyy.ccts.core.query.data.Queryable;
import com.byyy.ccts.core.query.parse.QueryToWrapper;
import com.byyy.ccts.modules.cc.entity.ccts.TAChillCar;
import com.byyy.ccts.modules.cc.entity.ccts.TADevice;
import com.byyy.ccts.modules.cc.mapper.ChillCarMapper;
import com.byyy.ccts.modules.cc.service.IChillCarService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by DELL on 2018-6-13.
 */
@Transactional
@Service("chillCarService")
public class ChillCarService extends CommonServiceImpl<ChillCarMapper, TAChillCar> implements IChillCarService {

    @Override
    public Page<TAChillCar> chillCarListForZcdMx(Queryable queryable, Wrapper<TAChillCar> wrapper, List<String> zhuangcdNos) {
        QueryToWrapper<TAChillCar> queryToWrapper = new QueryToWrapper<>();
        queryToWrapper.parseCondition(wrapper, queryable);
        // 排序问题
        queryToWrapper.parseSort(wrapper, queryable);
        Pageable pageable = queryable.getPageable();
        com.baomidou.mybatisplus.plugins.Page<TAChillCar> page = new com.baomidou.mybatisplus.plugins.Page<TAChillCar>(
                pageable.getPageNumber(), pageable.getPageSize());
        com.baomidou.mybatisplus.plugins.Page<TAChillCar> content = chillCarListPageForZcdMx(page, wrapper, zhuangcdNos);
        return new PageImpl<TAChillCar>(content.getRecords(), queryable.getPageable(), content.getTotal());
    }

    @Override
    public com.baomidou.mybatisplus.plugins.Page<TAChillCar> chillCarListPageForZcdMx(com.baomidou.mybatisplus.plugins.Page<TAChillCar> page, Wrapper<TAChillCar> wrapper, List<String> zhuangcdNos) {
        page.setRecords(baseMapper.selectChillCarPage(page, wrapper, zhuangcdNos));
        return page;
    }

    /**
     * 冷藏车列表查询
     * @param queryable
     * @param wrapper
     * @return
     */
    @Override
    public com.byyy.ccts.core.query.data.Page<TAChillCar> carInfoList(Queryable queryable, Wrapper<TAChillCar> wrapper) {
        QueryToWrapper<TAChillCar> queryToWrapper = new QueryToWrapper<>();
        queryToWrapper.parseCondition(wrapper, queryable);
        // 排序问题
        queryToWrapper.parseSort(wrapper, queryable);
        Pageable pageable = queryable.getPageable();
        com.baomidou.mybatisplus.plugins.Page<TAChillCar> page = new com.baomidou.mybatisplus.plugins.Page<TAChillCar>(
                pageable.getPageNumber(), pageable.getPageSize());
        com.baomidou.mybatisplus.plugins.Page<TAChillCar> content = carInfoListPage(page, wrapper);
        return new PageImpl<TAChillCar>(content.getRecords(), queryable.getPageable(), content.getTotal());
    }

    /**
     * 冷藏车列表查询
     * @param page
     * @param wrapper
     * @return
     */
    @Override
    public com.baomidou.mybatisplus.plugins.Page<TAChillCar> carInfoListPage(com.baomidou.mybatisplus.plugins.Page<TAChillCar> page, Wrapper<TAChillCar> wrapper) {
        page.setRecords(baseMapper.selectCarInfoPage(page, wrapper));
        return page;
    }

}
